package ev.space;

import ev.agent.Substation;
import ev.utility.DataReader;

import swarm.Globals;
import swarm.defobj.Zone;
import swarm.space.Grid2dImpl;
import swarm.collections.List;
import swarm.collections.ListImpl;
public class SubSpace extends Grid2dImpl{
	public static final List subList = new ListImpl(Globals.env.globalZone);
	public SubSpace(Zone aZone,int xSize,int ySize){
		super(aZone,xSize,ySize);
		fastFillWithObject(null);
		this.addSubs();
	}

	public void addSubs(){
		String  subDat = "bin/ev/source/subDat.txt";
		Substation substation;
		// the subDat format is: subNum gridnode xPos yPos
		DataReader dr = new DataReader(subDat);
		String tempString = "";
		String[] temp = new String[10];
		while((tempString = dr.readLine()) != null){
			temp = tempString.split(" ");
			substation = new Substation(Globals.env.globalZone,Integer.parseInt(temp[0]),Integer.parseInt(temp[1]));
			substation.setPos(Integer.parseInt(temp[2]),Integer.parseInt(temp[3]));
			putObject$atX$Y(substation,Integer.parseInt(temp[2]),Integer.parseInt(temp[3]));
			subList.addLast(substation);
		}
		dr.close();
	}
}
